<template>
  <div class="content">
    <div style="margin-top: 5rem;">
      <h3>{{ $route.meta.title }}</h3>
      <el-divider />
    </div>
    <div>
      <div class="box">
        <div class="boxtitle">
          一个节点
        </div>
        <div class="boxcontent">
          USDT：
          <div class="int">
            <el-input v-model="params.oneUsdtCnt" type="text" />
          </div>
          + BOK：
          <div class="int">
            <el-input v-model="params.oneBokCnt" type="text" />
          </div>
          &nbsp;&nbsp; &nbsp; &nbsp;
          <el-button type="primary" @click="determine(1)">确定</el-button>
        </div>
      </div>
      <!-- 5 -->
      <div class="box">
        <div class="boxtitle">
          五个节点
        </div>
        <div class="boxcontent">
          USDT：
          <div class="int">
            <el-input v-model="params.fiveUsdtCnt" type="text" />
          </div>
          + BOK：
          <div class="int">
            <el-input v-model="params.fiveBokCnt" type="text" />
          </div>
          &nbsp;&nbsp; &nbsp; &nbsp;
          <el-button type="primary" @click="determine(5)">确定</el-button>
        </div>
      </div>
      <!-- 10 -->
      <div class="box">
        <div class="boxtitle">
          十个节点
        </div>
        <div class="boxcontent">
          USDT：
          <div class="int">
            <el-input v-model="params.tenUsdtCnt" type="text" />
          </div>
          + BOK：
          <div class="int">
            <el-input v-model="params.tenBokCnt" type="text" />
          </div>
          &nbsp;&nbsp; &nbsp; &nbsp;
          <el-button type="primary" @click="determine(10)">确定</el-button>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import { getNodeMoneyConf, nodeMoneyConf } from '@/api/jackbo/platform.js'
export default {
  name: 'Nodeamount',
  data() {
    return {
      params: {
        fiveBokCnt: '',
        fiveUsdtCnt: '',
        oneBokCnt: '',
        oneUsdtCnt: '',
        tenBokCnt: '',
        tenUsdtCnt: ''
      }
    }
  },
  mounted() {
    this.getlist()
  },
  methods: {
    async getlist() {
      const res = await getNodeMoneyConf()
      if (res.code == 0) {
        for (const key in res.data) {
          res.data[key] = parseInt(res.data[key])
        }
        this.params = res.data
      }
    },
    async determine(obj) {
      const params = {}
      if (obj == 1) {
        params.type = 1
        params.usdtCnt = this.params.oneUsdtCnt
        params.bokCnt = this.params.oneBokCnt
      } else if (obj == 5) {
        params.type = 2
        params.usdtCnt = this.params.fiveUsdtCnt
        params.bokCnt = this.params.fiveBokCnt
      } else if (obj == 10) {
        params.type = 3
        params.usdtCnt = this.params.tenUsdtCnt
        params.bokCnt = this.params.tenBokCnt
      }
      const res = await nodeMoneyConf(params)
      if (res.code == 0) {
        this.getlist()
      }
      console.log(obj)
      // this.$message('我是确定')
    }
  }
}
</script>
<style scoped>
.box {
  /* height:8rem; */
  padding: 1rem;
  border: 1px solid #dddddd;
  border-radius: 0.5rem;
  width: 98%;
  margin: 0 auto;
  /* border; */
  margin-top: 2rem;
}
.boxtitle {
  font-size: 1.25rem;
  height: 3rem;
  line-height: 3rem;
}
.int {
  display: inline-block;
  width: 10rem;
}
.boxcontent {
  font-size: 1.25rem;
  height: 3rem;
  line-height: 3rem;
}
</style>
